import { DlgLogin } from "../dialog/DlgLogin";
import { MainContexMenu } from "./Main/MainContextMenu";

export enum LayerEnum{
    dialog,
    msgbox,
    tips,
    num,
}

interface CallbackFrame {
	frame: number;
	callback: ()=>void;
	self: any;
}

export class MainWindow extends eui.UILayer {
	private static instance: MainWindow;

	public static ins(): MainWindow {
		if (!this.instance) {
			this.instance = new MainWindow();
		}
		return this.instance;
	}

	createWindow():void{
		this.createLayers();
		this.contexMenu = new MainContexMenu(this);
		this.contexMenu.touchChildren = true;
		this.contexMenu.touchEnabled = false;
		this.addChild(this.contexMenu);
	}

    layers:eui.UILayer[] = [];

    createLayers(){
        for (let i = 0; i < LayerEnum.num; i++){
            let l = new eui.UILayer;
            l.touchThrough = true;
            l.touchEnabled = false;

            this.addChild(l);
            this.layers[i] = l;
        }
    }
    getLayer(l:LayerEnum){
        return this.layers[l];
    }

    showLogin(){
        let dlg = new DlgLogin();
        this.getLayer(LayerEnum.dialog).addChild(dlg);
        //this.addChild(dlg);
	}	
	
	contexMenu: MainContexMenu;
}